package com.skeryl.sqlite.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author coolszy
 * @blog http://blog.csdn.net/coolszy
 */
public class DBOpenHelper extends SQLiteOpenHelper
{
	private SQLiteDatabase checkDB = null;
	private static final int VERSION = 1;
	private static String DB_PATH = "/data/data/com.skeryl.sqlite.activity/databases/";
	private static final String DB_NAME = "data.db";
	private static final String debug_error = "database error";

	// checkDB = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null,
	// SQLiteDatabase.OPEN_READONLY);

	public DBOpenHelper(Context context)
	{
		super(context, DB_PATH + DB_NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		// db.execSQL("create table t_student (sid integer primary key,name varchar(20),age integer)");

		checkDB = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, SQLiteDatabase.OPEN_READONLY);
		if (checkDB != null)
		{
			db = checkDB;
		} else
		{
			db.execSQL("create table t_chapter (sid integer primary key,title varchar(30),content varchar(200))");
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{

	}

}
